#include "stdafx.h"
#include "IOCPModel.h"
#include "IOCPAsynListenerSocket.h"
#include "IOCPAsynServerSocket.h"
#include "IOCPThreads.h"
#include "IOCPAsynConnectionSocket.h"
#include "IOCPDataProcessor.h"

#include <iostream>
#include <sstream>

int _tmain(int argc, _TCHAR* argv[])
{

	CIOCPModel mainIOCP;
	mainIOCP.Create();

	CIOCPThreads threads(&mainIOCP);

	threads.Start();

	CIOCPConnectionPool connectionPool;
	connectionPool.Create(&mainIOCP);

	CIOCPDataProcessor dataProcessor;
	dataProcessor.Create();

	CIOCPAsynListenerSocket listener;
	listener.Create(&mainIOCP,&connectionPool,&dataProcessor,"192.168.0.68",12345,10);



	int a;

	std::cin>>a;

	char* buff = new char[10];
	int nLen = 6;
	memcpy(buff,&nLen,4);
	memcpy(buff + 4,"abcdef",6);

	CIOCPAsynServerSocket server;
	server.Create(&mainIOCP,&dataProcessor,"192.168.0.68",12345);
	server.PostConnect(buff,10);

	std::cin>>a;



	listener.Close();

	dataProcessor.Close();

	connectionPool.Close();

	threads.Stop();
	
	mainIOCP.Close();

	return 0;
}
